﻿using ConfExpert.Forms.Base;
using DevExpress.XtraEditors.Repository;
using DevTeam;

using System;
using System.Data;
using System.Drawing;

namespace ConfExpert.Forms.SatinAlma.YeniYapi
{
    public partial class SonGelisler : XForm
    {
        public SonGelisler()
        {
            InitializeComponent();
        }

        private void SonGelisler_Load(object sender, EventArgs e)
        {
            DataTable dtCust = Session.DataManager.ExecuteDataTable("GetMyCustomers2", WhoAmI);
            RepositoryItemGridLookUpEdit riCust = GetCustomGLE(dtCust, "Name", "CustomerId");

            gleMusteri.Edit.Assign(riCust);
            ((RepositoryItemGridLookUpEdit)gleMusteri.Edit).TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;
            gleMusteri.EditValueChanged += GleMusteri_EditValueChanged;

            //gv.RowStyle += gridView1_RowStyle;
        }

        void gridView1_RowStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs e)
        {
            if (e.RowHandle > -1)
            {
                if (gv.GetRowCellValue(e.RowHandle, "KontrolTarihi") != DBNull.Value)
                    e.Appearance.BackColor = e.Appearance.BackColor2 = Color.SkyBlue;
                else
                    e.Appearance.Combine((e.RowHandle & 1) != 0 ? gv.Appearance.EvenRow : gv.Appearance.OddRow);
            }
        }

        private void GleMusteri_EditValueChanged(object sender, EventArgs e)
        {
            gv.Init("GetSonGelis", intParse(gleMusteri.EditValue));
            gv.MakeReadOnly();
            //gv.OptionsView.EnableAppearanceOddRow = gv.OptionsView.EnableAppearanceEvenRow = false;
            gv.FormatAsDate("GelisTarihi");
            gv.FormatAsNumber(1, "QtyGelen", "QtyMevcut");
            gv.AddSummary("QtyGelen", "QtyMevcut");
            gv.BestFitColumns();
        }
    }
}
